//
//  ViewController.m
//  yidongshoushi
//
//  Created by blue on 15-12-21.
//  Copyright (c) 2015年 ZX. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
{
    UIView * view;
    
    
    
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    view = [[UIView alloc]initWithFrame:CGRectMake(5, 100, 100, 100)];
    view.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:view];
    
    //上下左右移动
    UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(onpan:)];
    [view addGestureRecognizer:pan];
    
    //放大缩小
    UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(onpinch:)];
    [view addGestureRecognizer:pinch];
    
    //旋转
    UIRotationGestureRecognizer * rot = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(onrot:)];
    [view addGestureRecognizer:rot];
    
    //轻拍
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(ontap:)];
    [view addGestureRecognizer:tap];
    
    //长按
    UILongPressGestureRecognizer * Long =[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(onlong:)];
    [view addGestureRecognizer:Long];
    
    //警告
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"警告" style:UIBarButtonItemStylePlain target:self action:@selector(alert:)];
    
    
}

//上下左右移动
- (void)onpan:(UIPanGestureRecognizer *)pan
{
    CGPoint p = [pan translationInView:self.view];
//    CGRect rect = view.frame;
//    rect.origin.x += p.x;
//    rect.origin.y += p.y;
//    pan.view.frame = rect;
    
    pan.view.transform = CGAffineTransformTranslate(pan.view.transform, p.x, p.y);
    [pan setTranslation:CGPointZero inView:self.view];
}

//放大缩小
- (void)onpinch:(UIPinchGestureRecognizer *)pinch
{
    pinch.view.transform = CGAffineTransformMakeScale(pinch.scale, pinch.scale);
}

//旋转
- (void)onrot:(UIRotationGestureRecognizer *)rot
{
    rot.view.transform = CGAffineTransformMakeRotation(rot.rotation);
    
}

//轻拍
- (void)ontap:()tap
{
    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"提示" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
}

//长按
- (void)onlong:()Long
{
    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"提示内容" delegate:nil cancelButtonTitle:@"取消"otherButtonTitles:nil];
    [alert show];

}

//警告
- (void)alert:()section
{
    UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"警告提示" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [aler show];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
